<?php
		$result = null;		
   		$upload = wp_upload_dir();
   		
	 	if(isset($_GET['option']) && $_GET['option']=="company_setting_logo")
   		{
   			$link = $_GET['option'];
   			$path_name = get_option("company_setting_logo");
   			$dirpath = $upload['basedir'].$path_name;   			
   			unlink($dirpath);
   			delete_option("company_setting_logo");
   			$ulr = get_bloginfo('home')."/wp-admin/admin.php?page=my-setting";
   			wp_redirect($ulr);
   		} 
?>
<!-- Cập nhật tùy chỉnh trang mail managerment -->                     
<div id="index_page" class="index_page">
   		<?php
   		   		
        if ( !empty($_POST) && wp_verify_nonce($_POST['company_logo_managerment'],'company_logo_managerment') )
          {
		          	$slogan = $_POST['mySetting_company_slogan'];
		          	update_option("mySetting_company_slogan", $slogan);
          			$overrides = array('test_form' => false);          			
          			//$title = $_POST['mySetting_photo_title'];
          			//$shortdes = $_POST['mySetting_photo_shortdes'];
          			$result = "Update Sucess!";
          			##++++++++++++++++++++++++++++++++++++++++++++++++
					if($_FILES['file_logo']['size']>0)
					{							
						$file_path = $upload['path'].'/';
						$file_name = $file_path.$_FILES['file_logo']['name'];
						
						if(file_exists($file_name))
						{
							$result = "<p style='color:red;'>Sorry!File <span style='color:#000000;'>".$_FILES['file_logo']['name']."</span> already exists, update failed,Please try again with other file name.</p>";	
						}
						else 
						{
							$subdir = $upload['subdir'].'/';							
							$subdir = $subdir.$_FILES['file_logo']['name'];
							
							$file = wp_handle_upload($_FILES['file_logo'], $overrides);						
							//db_insert_photo($title, $shortdes,$subdir);
							update_option( 'company_setting_logo',$subdir);
							$result = "Update Sucess!";
							//echo 'adfa';
						}
																		
					}          		          		
          ?>
          		<div id="index_message" name="index_message" class="updated"><?php echo $result;?></div>
          <?php
          }
        ?>  
   <form action="" method="post" id="logo_index_page" enctype="multipart/form-data">
   	
   	<label for="mySetting_company_slogan"><strong>Site Slogan</strong><em></em></label><br/>
     <input type="text" name="mySetting_company_slogan" size="65"  value="<?php echo esc_attr( get_option('mySetting_company_slogan') ); ?>"/><br/>
   
   	 <label for="mySetting_company_logo"><strong>Upload Logo</strong><em></em></label><br/>
     <input type="file" size="10" name="file_logo" value="Upload" /> <br/>     
              
    <input type="submit" value="Cập nhật" style="border-style:outset;border-width: 2px;font-weight: bold" /></p>
    
    <div class="image_photo">
		<img alt="" src="<?php echo $upload['baseurl'].get_option("company_setting_logo");?>">
		<a class="delete_photo" href="<?php bloginfo('home');?>/wp-admin/admin.php?page=my-setting&option=company_setting_logo">Delete</a>
	</div>
			
    <?php wp_nonce_field('company_logo_managerment','company_logo_managerment'); ?>

   </form>		           
</div>